package com.bdy.lm.taximanager.ui;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import com.bdy.lm.taximanager.R;
import com.bdy.lm.taximanager.app.MyApp;
import com.bdy.lm.taximanager.http.HttpJson;
import com.bdy.lm.taximanager.model.MessagePackaging;
import com.bdy.lm.taximanager.model.SerialPortData;
import com.bdy.lm.taximanager.model.Taxi;
import com.bdy.lm.taximanager.port.TaxiMeterDataAnalysis;
import com.bdy.lm.taximanager.util.JsonUtils;
import com.bdy.lm.taximanager.util.ToastUtils;

import org.json.JSONObject;

import static com.bdy.lm.taximanager.app.MyApp.serverUrl;

public class TaxiInfoActivity extends AppCompatActivity {

    private TextView licenseColor, companyID, ISUFlag, runLicense, engineID, frameID, factoryID, fuel, buyDate, transportID;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_taxi_info);

        licenseColor = (TextView) findViewById(R.id.license_color);
        companyID = (TextView) findViewById(R.id.company_id);
        ISUFlag = (TextView) findViewById(R.id.isu_flag);
        runLicense = (TextView) findViewById(R.id.run_license);
        engineID = (TextView) findViewById(R.id.engine_id);
        frameID = (TextView) findViewById(R.id.frame_id);
        factoryID = (TextView) findViewById(R.id.factory_id);
        fuel = (TextView) findViewById(R.id.fuel);
        buyDate = (TextView) findViewById(R.id.buy_date);
        transportID = (TextView) findViewById(R.id.transport_id);

        if (MyApp.taxi == null) {
            alert("正在查询，请稍后...");
        } else {
            setTextView();
        }
    }

    private void setTextView(){
        licenseColor.setText(MyApp.taxi.getLicenseColor());
        companyID.setText(MyApp.taxi.getCompanyId());
        ISUFlag.setText(MyApp.taxi.getISUFlag());
        runLicense.setText(MyApp.taxi.getRunLicense());
        engineID.setText(MyApp.taxi.getEngineId());
        frameID.setText(MyApp.taxi.getFrameId());
        factoryID.setText(MyApp.taxi.getFactoryId());
        fuel.setText(MyApp.taxi.getFuel());
        buyDate.setText(MyApp.taxi.getBuyDate());
        transportID.setText(MyApp.taxi.getTransportId());
    }

    /**
     *  提醒
     * @param s 提醒内容
     */
    private void alert(String s) {
        new AlertDialog.Builder(this).setTitle("提示！！！").setPositiveButton("确定", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface paramAnonymousDialogInterface, int paramAnonymousInt) {
            }
        }).setMessage(s).create().show();
    }
}
